<template>
  <div class="top">
    <van-image
      round
      width="7rem"
      height="7rem"
      :src="require('../../assets/mju-logo.jpg')"
    />
    <van-form @submit="onSubmit" >
      <van-field
        v-model="username"
        name="username"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px;">
        <van-button round block color="#87CEFA" plain native-type="submit">
          提交
        </van-button>

      </div>
    </van-form>
    <van-row type="flex" justify="center">
      <van-col span="6" align="center" @click="toRegister">注册用户</van-col>
      <van-col span="6" align="center">|</van-col>
      <van-col span="6" align="center" @click="retrievePassword">找回密码</van-col>
    </van-row>

  </div>
</template>

<script>
    import state from "../../store/state";

    export default {
      name: "Login",
      data() {
        return {
          username: '',
          password: '',
        };
      },
      methods: {
        onSubmit(values) {
          console.log('submit', values.username);
          state.username=values.username;
          this.$router.replace({path: '/my'});
        },
        toRegister(){
          this.$router.replace({path: '/register'});
        },
        retrievePassword(){
          console.log("retrievePassword")
        }
      },
    }
</script>

<style scoped>
  .top{
    text-align: center;
    margin: 110px auto;
    padding: 20px;
    padding: 35px 35px 35px 35px;
  }
</style>
